/*
package com.pearl.jacksoncore.demo.databind.ser;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.BeanDescription;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializationConfig;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.introspect.Annotated;
import com.fasterxml.jackson.databind.ser.BeanPropertyWriter;
import com.fasterxml.jackson.databind.ser.BeanSerializerModifier;

import java.util.ArrayList;
import java.util.List;

*/
/**
 * @author TD
 * @version 1.0
 * @date 2024/4/11
 *//*

public class ExtraFieldBeanSerializerModifier extends BeanSerializerModifier {

    @Override
    public List<BeanPropertyWriter> changeProperties(SerializationConfig config,
                                                     BeanDescription beanDesc,
                                                     List<BeanPropertyWriter> beanProperties) {
        // 复制原始属性列表
        List<BeanPropertyWriter> modifiedProperties = new ArrayList<>(beanProperties);

        BeanPropertyWriter beanPropertyWriter = new BeanPropertyWriter();

        // 添加一个额外的属性
        modifiedProperties.add(new BeanPropertyWriter(beanDesc.findPropertyIndex("extraField")) {
            @Override
            public void serializeAsField(Object bean, JsonGenerator gen, SerializerProvider serializers) throws Exception {
                gen.writeStringField("extraField", "This is an extra field value");
            }

            @Override
            public JsonSerializer<?> getSerializer(SerializerProvider serializers) {
                return this;
            }

            @Override
            public Annotated getMember() {
                return null; // 因为我们没有真正的成员，所以返回 null
            }

            @Override
            public boolean isUnwrappingSingle(SerializerProvider serializers) {
                return false;
            }
        });

        return modifiedProperties;
    }
}
*/
